<!-- chart5 -->
<template>
  <div class="chart5">
    <div v-if="!loadingFlag" class="chart51">
      <div class="chart51-title">{{ this.title1 }}</div>
      <div class="chart51-info">
        <div
          class="info-box"
          style="background-color: rgba(103, 224, 227, 0.3)"
          @click="toListPage('postGetEmergencyMList','当月电梯救援数量',0)"
        >
          <span>当月救援数量</span>
          <span>{{lookTaskData.rescueMNum || '0'}}</span>
        </div>
        <div
          class="info-box"
          style="background-color: rgba(230, 144, 209, 0.2)"
          @click="toListPage('postGetEmergencyAList','累计电梯救援数量',0)"
        >
          <span>累计救援数量</span>
          <span>{{lookTaskData.rescueANum || '0'}}</span>
        </div>
      </div>
    </div>
    <div v-if="!loadingFlag" class="chart51 next">
      <div class="chart51-title">{{ this.title2 }}</div>
      <div class="chart51-info">
        <div class="info-box" @click="toListPage('postGetMHiddenList','当月监察任务',0)">
          <span>当月监察任务</span>
          <span>{{lookTaskData.tasksMNum || '0'}}</span>
        </div>
        <div class="info-box" @click="toListPage('postGetMonitorTList','累计监察任务',0)">
          <span>累计监察任务</span>
          <span>{{lookTaskData.tasksANum || '0'}}</span>
        </div>
        <div class="info-box" @click="toListPage('postGetMWornHiddenList',' 当月预警监察列表',0)">
          <span>预警监察任务</span>
          <span>{{lookTaskData.tasksWMNum || '0'}}</span>
        </div>
        <div class="info-box" @click="toListPage('postGetMWornMonitorList','累计预警监察列表',0)">
          <span>累计预警监察</span>
          <span>{{lookTaskData.tasksWANum || '0'}}</span>
        </div>
      </div>
    </div>
    <div v-if="loadingFlag" class="e-loading">
      <dv-loading style="color: #fff">监察情况数据加载中...</dv-loading>
    </div>
  </div>
</template>

<script>
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      title1: "电梯应急救援情况",
      title2: "监察情况",
      loadingFlag: true,
      lookTaskData: {}
    };
  },
  //监听属性 类似于data概念
  // computed: {
  //   areaCode() {
  //     return this.$store.state.listAreaIndex;
  //   },
  // },
  // //监控data中的数据变化
  // watch: {
  //   areaCode(newVal, oldVal) {
  //     console.log("区域code有改动 -- chart5: [" + newVal + "]");
  //     this.init();
  //   },
  // },
  //方法集合
  methods: {
    toListPage(dataType, title, index) {
      this.$store.commit("clearIndex");
      this.$store.commit("setListCategory", dataType);
      this.$store.commit("setListTitle", title);
      this.$store.commit("setListTypeIndex", index);
      let params = {};
      this.$router.push({
        name: "list-page",
        params: params,
      });
    },
    init() {
      this.loadingFlag = true;
      let area_code = this.$store.getters.getAreaList[
        this.$store.getters.getListAreaIndex
      ]["area_code"];
      let params = { area_code };
      this.$http.postScreenlookTask(params).then((e) => {
        let ret = e.data;
        if (ret.errorCode != 0) {
          console.log("后台运行异常!");
          return console.log(ret);
        }
        // console.log(ret);
        this.lookTaskData = ret.data

        this.$nextTick(() => {
          //   this.chart6(ret.data);
          // console.log(this.lookTaskData);
          this.loadingFlag = false;
        });
      });
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.init()
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='less' scoped>
//@import url(); 引入公共css类
.chart5 {
  width: 100%;
  height: 100%;
  position: relative;
  .chart51 {
    position: absolute;
    top: 60%;
    width: 100%;
    height: 35%;
    color: @FontColor;
    .chart51-title {
      // background-color: #141b47;
      color: @FontColor;
      font-size: 0.22rem;
      font-weight: bold;
      height: 30%;
      line-height: 100%;
    }
    .chart51-info {
      height: 70%;
      font-size: 0.2rem;
      display: flex;
      flex-wrap: wrap;
      .info-box {
        // flex: 1;
        width: 50%;
        display: flex;
        justify-content: space-evenly;
        align-items: center;
        border-radius: 4%;
      }
    }
  }
  .chart51.next {
    left: 0;
    top: 5%;
    width: 100%;
    height: 50%;
    .chart51-info {
      background-color: rgba(159, 230, 184, 0.2);
    }
  }
  .e-loading {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
  }
}
</style>